package com.lanou.dllo.findfood.volley;

import android.graphics.Bitmap;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by dllo on 15/10/22.
 */
public class DoubleCache implements ImageLoader.ImageCache {
    private ImageLoader.ImageCache memoryCache;
    private ImageLoader.ImageCache disCache;
    public DoubleCache(){
        memoryCache = new MemoryCache();
        disCache = new DiskCache();
    }


    @Override
    public Bitmap getBitmap(String url) {
        Bitmap bitmap = memoryCache.getBitmap( url);
        if (bitmap == null){
            bitmap = disCache.getBitmap(url);
        }

        return bitmap;
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {

        memoryCache.putBitmap(url,bitmap);
        disCache.putBitmap(url,bitmap);
    }
}
